// Copyright 2014 Google Inc. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
/**
 * @fileoverview Tests for the Tee helper class.
 *
 * @author rcc@google.com (Ryan Chan)
 */

goog.require('e2e.otr.testing');
goog.require('e2e.otr.util.Tee');
goog.require('goog.testing.asserts');
goog.require('goog.testing.jsunit');

goog.setTestOnly();


function testConstructor() {
  var storage = [];
  assertEquals(storage, new e2e.otr.util.Tee(storage).storage_);
  assertNotEquals(storage, new e2e.otr.util.Tee().storage_);
}

function testTeeAndDump() {
  var storage = [];
  var t = new e2e.otr.util.Tee(storage);
  t.tee([1, 2, 3, 4, 5]);
  assertArrayEquals([1, 2, 3, 4, 5], storage);
  t.tee(new Uint8Array([6, 7]));
  assertArrayEquals([1, 2, 3, 4, 5, 6, 7], storage);
  assertEquals(storage, t.dump());

  var t = new e2e.otr.util.Tee();
  t.tee([1, 2, 3, 4, 5]);
  assertArrayEquals([1, 2, 3, 4, 5], t.dump());
  t.tee(new Uint8Array([6, 7]));
  assertArrayEquals([1, 2, 3, 4, 5, 6, 7], t.dump());
}

